package com.xxj.fflink;

import android.content.Context;
import android.graphics.Color;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup.LayoutParams;

import com.wooboo.adlib_android.ImpressionAdView;
import com.wooboo.adlib_android.WoobooAdView;

public class AdUtil {

	private static Context context;

	private static final String Wooboo_PID = "e4e94ccf04b747e3a8cc822402be1cf1";

	/**
	 * 
	 * 
	 * @return
	 */
	public static WoobooAdView getWoobooAdView() {
		WoobooAdView ad = new WoobooAdView(context, // Context
				Wooboo_PID, // Wooboo_PID
				Color.TRANSPARENT, Color.WHITE, true, 30, null);
		LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT,
				LayoutParams.WRAP_CONTENT);
		ad.setLayoutParams(params);

		return ad;
	}

	/**
	 * ����ʽ���(�ɹر�,��ʱ�Ե�) λ��������
	 * 
	 * @param mainView
	 * @param context
	 */
	public static void embAdBottom(View mainView, Context context) {
		DisplayMetrics dm = new DisplayMetrics();
		dm = context.getResources().getDisplayMetrics();
		double density = dm.density;
		int adWidth = (int) (density * 320); // �����
		int adHeight = (int) (density * 48); // ���߶�
		int x = (dm.widthPixels - adWidth) >> 1;
		int y = dm.heightPixels - adHeight;

		embAd(mainView, context, x, y);
	}

	public static void embAdTop(View mainView, Context context) {
		embAd(mainView, context, 0, 0);
	}

	private static void embAd(View mainView, Context context, int x, int y) {
		ImpressionAdView ad = new ImpressionAdView(context, mainView, 0, 0, 0xFFFFFFFF, false, null);
		ad.show(20);
	}
}
